package com.fyp.ptma.dao.repository.irepository;

import javax.persistence.PersistenceException;

import org.hibernate.Session;
import org.hibernate.exception.ConstraintViolationException;

/**
 * 
 * @author YahyaArshad Every Dao should extends this interface. Every class
 *         implementing its concrete implementation should provide
 *         implementation should provide implementation for CRUD methdos
 */
public abstract interface IDao {
	/**
	 * 
	 * @param objToSave
	 * @return
	 * @throws PersistenceException
	 * @throws ConstraintViolationException
	 */
	public Long save(Object objToSave) throws PersistenceException,
			ConstraintViolationException;

	/**
	 * 
	 * @param objToUpdate
	 * @return
	 * @throws PersistenceException
	 */
	public Long update(Object objToUpdate) throws PersistenceException;

	/**
	 * 
	 * @param objToDelete
	 * @return
	 * @throws PersistenceException
	 * @throws ConstraintViolationException
	 */
	public boolean delete(Object objToDelete) throws PersistenceException,
			ConstraintViolationException;

	public void saveOrUpdate(Object objToSave) throws PersistenceException,
			ConstraintViolationException;

	/**
	 * 
	 * @return
	 */
	public Session openSession();

}
